package mysql

import "gorm.io/gorm"

type WeChat struct {
	gorm.Model
	Tel        string `gorm:"Type:varchar(30);not null"`
	Password   string `gorm:"type:char(32);not null"`
	Qq         string `gorm:"Type:varchar(30);not null"`
	Email      string `gorm:"Type:varchar(30);not null"`
	WeChatCode string `gorm:"Type:varchar(50);not null"`
}

func (c *WeChat) FindWeChatByTel(db *gorm.DB, tel string) error {
	return db.Debug().Where("tel=?", tel).Find(c).Error
}

func (c *WeChat) WeChatAdd(db *gorm.DB) error {
	return db.Debug().Create(c).Error
}

func (c *WeChat) FindWeChatByAccount(db *gorm.DB, qq string, email string, code string) error {
	return db.Debug().Where("qq=? or email=? or we_chat_code=?", qq, email, code).First(c).Error
}
